<template>
  <div id="case">
    <el-row>
      <el-col :span="4">
        <el-button type="primary" icon="el-icon-plus" @click="addInfo">添加病例</el-button>
      </el-col>
      <el-col :span="10" :offset="10">
        <list-style :listType="listType" @listTypeChange="listTypeChange"></list-style>
      </el-col>
    </el-row>
    <div class="pd_20 bg_white el_t_20">
      <el-row :gutter="20">
        <el-col :span="5" class="el-name">就诊科室：</el-col>
        <el-col :span="5" class="el-name">主诊医师：</el-col>
        <el-col :span="5" class="el-name">责任技师：</el-col>
        <el-col :span="5" class="el-name">案例信息：</el-col>
      </el-row>
      <el-row :gutter="20" class="el_t_10">
        <el-col :span="5">
          <el-select v-model="search.name" size="mini" placeholder="请选择就诊科室" class="el_long">
            <el-option label="请选择就诊科室" :value="1"></el-option>
          </el-select>
        </el-col>
        <el-col :span="5">
          <el-select v-model="search.name" size="mini" placeholder="请选择主任医生" class="el_long">
            <el-option label="请选择主任医生" :value="1"></el-option>
          </el-select>
        </el-col>
        <el-col :span="5">
          <el-select v-model="search.name" size="mini" placeholder="请选择责任技师" class="el_long">
            <el-option label="请选择责任技师" :value="1"></el-option>
          </el-select>
        </el-col>
        <el-col :span="5">
          <el-input type="text" size="mini" placeholder="输入门诊号 / 姓名 / 电话 / 诊断结果搜索"></el-input>
        </el-col>
        <el-col :span="2">
          <el-button type="primary" size="mini" class="el_long" v-if="!searchMore" plain>搜索</el-button>
          <template v-if="searchMore">&nbsp;</template>
        </el-col>
        <el-col :span="2">
          <el-button type="text" size="mini" class="el_long" @click="searchMore=!searchMore">
            {{searchMore?'收起':'更多'}}
            <i
              class="el-icon-d-arrow-right rotate"
              :class="{'active':searchMore}"
            ></i>
          </el-button>
        </el-col>
      </el-row>
      <el-row :gutter="20" class="el_t_20" v-if="searchMore">
        <el-col :span="5" class="el-name">推荐人：</el-col>
        <el-col :span="5" class="el-name">就诊类型：</el-col>
        <el-col :span="5" class="el-name">就诊时间：</el-col>
      </el-row>
      <el-row :gutter="20" class="el_t_10" v-if="searchMore">
        <el-col :span="5">
          <el-select v-model="search.name" size="mini" placeholder="请选择推荐人" class="el_long">
            <el-option label="请选择推荐人" :value="1"></el-option>
          </el-select>
        </el-col>
        <el-col :span="5">
          <el-select v-model="search.name" size="mini" placeholder="请选择就诊类型" class="el_long">
            <el-option label="请选择就诊类型" :value="1"></el-option>
          </el-select>
        </el-col>
        <el-col :span="8">
          <el-date-picker
            size="mini"
            class="el_long"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-col>
        <el-col :span="2">
          <el-button type="primary" class="el_long" size="mini" plain>搜索</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="content" :class="{active:searchMore}">
      <template v-if="listType === 1">
        <div class="box">
          <el-row :gutter="20" v-if="list.length > 0">
            <template v-for="(item,index) in list">
              <el-col :span="8">
                <div class="item">
                  <div class="case">
                    <div class="photo">
                      <img src="../img/photo.png" alt>
                    </div>
                    <div class="text">
                      <p>
                        <span v-html="item.name"></span>
                        {{`${item.sex} '('${item.birthday}')'`}}
                      </p>
                      <p>门诊号：{{item.no}}</p>
                      <p>电话：{{item.phone}}</p>
                      <p>就诊日期：{{item.time}}</p>
                      <p>
                        出诊：
                        <em v-html="item.remark"></em>
                      </p>
                    </div>
                  </div>
                  <div class="tools">
                    <el-row>
                      <el-col :span="12">
                        <el-button type="text" class="el_long" plain>查看/编辑</el-button>
                      </el-col>
                      <el-col :span="12">
                        <el-button type="text" class="el_long" plain @click="deleteMsg(item)">删除</el-button>
                      </el-col>
                    </el-row>
                  </div>
                </div>
              </el-col>
            </template>
          </el-row>
          <h2 v-else>系统未检索到相关结果…</h2>
        </div>
      </template>
      <template v-else>
        <el-table
          :data="list"
          :header-row-class-name="'table_header'"
          :height="list.length>0?280:110"
          :empty-text="'系统未检索到相关结果…'"
        >
          <el-table-column prop="no" label="门诊号" width="120"></el-table-column>
          <el-table-column prop="name" label="姓名" width="80"></el-table-column>
          <el-table-column prop="sex" label="性别" width="80"></el-table-column>
          <el-table-column prop="birthday" label="出生年月" width="120"></el-table-column>
          <el-table-column prop="phone" label="电话" width="150"></el-table-column>
          <el-table-column prop="time" label="就诊时间" width="200"></el-table-column>
          <el-table-column prop="name" label="就诊科室"></el-table-column>
          <el-table-column prop="name" label="就诊类型"></el-table-column>
          <el-table-column prop="name" label="主诊医师"></el-table-column>
          <el-table-column prop="name" label="初诊结果"></el-table-column>
          <el-table-column prop="name" label="推荐人"></el-table-column>
          <el-table-column prop="name" label="责任技师"></el-table-column>
          <el-table-column prop="name" label="操作" fixed="right" width="180">
            <template slot-scope="data">
              <el-button type="primary" plain size="mini" @click>查看/编辑</el-button>
              <el-button type="primary" plain size="mini" @click="deleteMsg(data.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>
    <div class="text-right el_t_20 page_box" v-if="list.length > 0">
      <el-pagination
        :current-page="1"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="list.length"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import listStyle from "@/components/common/listStyle";

export default {
  name: "index",
  data() {
    return {
      listType: 1,
      height: 0,
      searchMore: false,
      search: {
        name: ""
      },
      list: [
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍"
        },
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍"
        },
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍"
        },
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍"
        },
        {
          name: "胡忠信",
          sex: "男",
          birthday: "1956-12-10",
          no: "1812100102",
          phone: "15645541321",
          time: "2018-12-10 14:23:32",
          remark: "睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍睡眠障碍"
        }
      ]
    };
  },
  methods: {
    addInfo() {
      this.$router.push({ name: "caseBookEdit" });
    },
    listTypeChange(val) {
      this.listType = val;
    },
    deleteMsg(data) {
      this.$confirm("确定删除该条记录？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "点错了",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    }
  },
  components: {
    listStyle
  }
};
</script>

<style scoped>
.case {
  border-bottom: 1px solid rgb(194, 228, 198);
  overflow: hidden;
}

.item {
  width: 100%;
  border: 1px solid rgb(194, 228, 198);
  background: #f3fdf8;
}

.item .photo {
  width: 50px;
  height: 50px;
  float: left;
  margin: 20px;
}

.photo img {
  width: 100%;
}

.item .text {
  width: calc(100% - 90px);
  float: left;
  padding-top: 10px;
}

.text p {
  font-size: 12px;
  color: rgb(102, 102, 102);
  line-height: 1;
}

.text p span {
  font-size: 16px;
  font-weight: bold;
  color: #333333;
  margin-right: 20px;
}

em {
  display: inline-block;
  font-style: normal;
  width: calc(100% - 50px);
  overflow: hidden;
  -ms-text-overflow: ellipsis;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools {
  width: 100%;
  overflow: hidden;
}

.tools button {
  background: #ffffff !important;
  border: none !important;
}

.tools .el-row .el-col:first-child {
  border-right: 1px solid rgb(194, 228, 198);
}

.box > .el-row > .el-col {
  margin-bottom: 20px;
}

.content {
  margin-top: 10px;
  height: calc(100vh - 270px);
  background: #ffffff;
  position: relative;
  padding: 20px;
}

.content.active {
  height: calc(100vh - 347px);
}

.box {
  max-height: calc(100% - 50px);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.content.active .box {
  max-height: calc(100% - 40px);
}

.box h2 {
  font-size: 14px;
  font-weight: normal;
}

.page_box {
  right: 40px;
  bottom: 40px;
}

.rotate {
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  -o-transform: rotate(90deg);
  transform: rotate(90deg);
}

.rotate.active {
  -webkit-transform: rotate(-90deg);
  -moz-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  -o-transform: rotate(-90deg);
  transform: rotate(-90deg);
}
</style>
